<?php
	//
	//This php will handle the 
	// UserFetch.java 
	// - fetchUserById function
	//
	
	//Connect to database
	include '../../dbc.php';
	
	$restaurant_id = $_POST['id'];
	
	//Select non-blocked restaurant
    $query01 = "SELECT * FROM restaurant_comment WHERE restaurant='$restaurant_id' AND is_blocked='0'";
	$query01_result = mysql_query($query01);
	if(mysql_num_rows($query01_result) > 0){
		$i = 0;
		$sum = 0;
		while($query01_result_row = mysql_fetch_array($query01_result)){
			$sum = $sum + $query01_result_row['rating'];
			$i++;
		}
		
		$response["RATING"] = $sum/$i;
		$response["STATUS"] = "1";
		/*
		$response["NUMBER"] = $i;
		$response["ID"] = $id;
		$response["USER"] = $user;
		$response["RESTAURANT"] = $restaurant;
		$response["RATING"] = $rating;
		$response["COMMENT"] = $comment;
		$response["CREATE_DATE"] = $create_date;
		*/
		echo json_encode($response);
	}else{
		//Unable to get user
		$response["STATUS"] = "0";
		$response["NUMBER"] = "0";
		echo json_encode($response);
	}
	

?>